<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>四川省工程建设领域项目信息、信用信息公开维护平台</title>
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/reset.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/main.css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/My97DatePicker4/WdatePicker.js"></script>
<script src="<%=request.getContextPath()%>/scripts/jquery-latest.pack.js"></script>
<script src="<%=request.getContextPath()%>/scripts/jquery.form.js"></script>
<script type="text/javascript">
var submitFlag = true;
function check(){
	var f = document.getElementById("form1");
	if (f.userPassword.value == ""){
		alert("必须填写密码");
		f.userPassword.focus();
		return false;
	}
	if (f.userPassword.value.length < 4){
		alert("密码至少需要四位");
		f.userPassword.focus();
		return false;
	}
	if (f.deptName.value == ""){
		alert("必须填写部门名称");
		f.deptName.focus();
		return false;
	}
	if (f.companyAddr.value == ""){
		alert("必须填写地址");
		f.companyAddr.focus();
		return false;
	}
	if (f.contacter.value == ""){
		alert("必须填写联系人");
		f.contacter.focus();
		return false;
	}
	if (f.phone.value == ""){
		alert("必须填写电话");
		f.phone.focus();
		return false;
	}
	if (f.email.value == ""){
		alert("必须填写电子邮件");
		f.email.focus();
		return false;
	}
	return true;
}

function checkOrgCode(obj)
{
	if (obj.value != ""){
		if(obj.value.length < 9){
			var obj = document.getElementById("oCd");
			obj.innerHTML='<font color="#FF9966">该组织机构代码不正确</font>';
			return;
		}
		setTimeout(function(){checkOrgCodeDB(obj);}, 2000);
	}else{
		var obj = document.getElementById("oCd");
		obj.innerHTML='<font color="#FF9966">该组织机构代码不正确</font>';
		return;
	}
}

function checkOrgCodeDB(obj)
{
	var userID = $('#userID').val();
	var options={type:"POST", 
				url:"<%=request.getContextPath()%>/user/orgCodeAuthWithUserID?orgCode="+obj.value+"&userID="+userID, 
				dataType:"json", success: checkOrgCodeHandle};
	$.ajax(options);
}

function checkOrgCodeHandle(data,status) {
	var obj = document.getElementById("oCd");
	if(status){
		if (data.result == 0){
			obj.innerHTML='<font color="#669933">该组织机构代码可以注册</font>';
		}
		else{
			obj.innerHTML='<font color="#FF9966">该组织机构代码已被注册</font>';
		}
	}
	else{
		obj.innerHTML='<font color="#FFFF00">无法检测组织机构代码</font>';
	}
}

function checkOrgCodeWithUserID(){
	var orgCode = $('#orgCode').val();
	var userID = $('#userID').val();
	submitFlag = false;
	var options={type:"POST",
			data: "orgCode="+orgCode+"&userID="+userID,
			url:"<%=request.getContextPath()%>/user/orgCodeAuthWithUserID", 
			dataType:"json", success: checkOrgCodeHandleWithUserID};
	$.ajax(options);
}

function checkOrgCodeHandleWithUserID(data,status){
	submitFlag = true;
	if(status){
		if (data.result == 0){
			document.getElementById('form1').submit();
		}else{
			alert("组织机构代码已被占用，请确认后再试");
		}
	}else{
		alert('网络连接异常，请联系管理员');
	}
}

function edit(){
	if(!submitFlag){
		alert('请求已提交，请稍候');
		return;
	}
	if(!check()){
		return;
	}
	checkOrgCodeWithUserID();
}

function init() {
	${msg}
}
</script>
</head>
<body onload="init();">
<form method="post" id="form1" name="form1" action="<%=request.getContextPath()%>/user/editSelfUserInfo">
<table class="top">
  <tr>
    <td width="40" class="topl"></td>
    <td width="840"><div class="plat_title"><img src="<%=request.getContextPath()%>/images/toptitle.gif" /></div></td>
    <td width="21"><a href="#" class="top_drop_btn"></a></td>
    <td width="20"><a href="#" class="maxbtn"></a></td>
    <td width="29"><a href="#" class="closebtn"></a></td>
  </tr>
</table>
<table class="content">
  <tr>
    <td class="main_l"></td>
    <td class="main_lbar"></td>
    <td width="918" valign="top">
	<div class="banner"><img src="<%=request.getContextPath()%>/images/banner.jpg" /></div>
	<div class="op_con">
    <table class="regtable">
  <tr>
<th colspan="2">帐号信息</th>
  </tr>
  <tr>
  <td colspan="2"></td>
  </tr>
 
  <tr>
    <td class="w02">帐号</td>
    <td><input type="text" class="intt" value="${user.userAccount}" disabled="disabled"/><b>*</b></td>
  </tr>
  <tr>
    <td class="w02">密码</td>
    <td><input type="text" class="intt" id="userPassword" name="userPassword" value="${user.userPassword}" maxlength="6"/><b>*</b></td>
  </tr>
  <tr>
    <td class="w02">部门名称</td>
    <td><input type="text" class="intt" id="deptName" name="deptName" value="${user.orgName}" maxlength="50"/><b>*</b></td>
  </tr>
  <tr>
    <td class="w02">地址</td>
    <td><input type="text" class="intt" id="companyAddr" name="companyAddr" value="${user.companyAddr}" maxlength="50"/><b>*</b></td>
  </tr>
  <tr>
    <td class="w02">联系人</td>
    <td><input type="text" class="intt" id="contacter" name="contacter" value="${user.contacter}" maxlength="50"/><b>*</b></td>
  </tr>
  <tr>
    <td class="w02">联系电话</td>
    <td><input type="text" class="intt" id="phone" name="phone" value="${user.phone}" maxlength="50"/><b>*</b></td>
  </tr>
  <tr>
    <td class="w02">电子邮件</td>
    <td><input type="text" class="intt" id="email" name="email" value="${user.email}" maxlength="50"/><b>*</b></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
    <input type="hidden" name="userID" id="userID" name="userID" value="${user.userID}"/>
    <input type="button" value="保存" class="btn40" onclick="edit();"/></td>
  </tr>
    <tr>
  <td colspan="2"></td>
  </tr>
</table>

	</div>
	</td>
    <td class="main_rbar"></td>
	<td class="main_r"></td>
  </tr>
</table>
</form>
<table class="bot">
	<tr>
		<td width="41"><div class="botl"></div></td>
		<td width="867"></td>
		<td width="42"><div class="exit"></div></td>
	</tr>
</table>
<c:import url="/foot.jsp" />
</body>
</html>
